package com.erp.framework.service.impl;


import com.erp.framework.core.text.Convert;
import com.erp.framework.domain.SysOperaLog;
import com.erp.framework.mapper.SysOperaLogMapper;
import com.erp.framework.service.ISysOperaLogService;
import com.erp.framework.util.AutoFillUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 操作日志 服务层处理
 *
 * @author erp
 */
@Service
public class SysOperaLogServiceImpl implements ISysOperaLogService {

    @Autowired
    private SysOperaLogMapper operaLogMapper;

    /**
     * 新增操作日志
     *
     * @param operaLog 操作日志对象
     */
    @Override
    public void insert(SysOperaLog operaLog) {
        AutoFillUtils.setCreateInfo(operaLog);
        operaLogMapper.insertOperaLog(operaLog);
    }

    /**
     * 查询系统操作日志集合
     *
     * @param operaLog 操作日志对象
     * @return 操作日志集合
     */
    @Override
    public List<SysOperaLog> list(SysOperaLog operaLog) {
        return operaLogMapper.list(operaLog);
    }

    /**
     * 批量删除系统操作日志
     *
     * @param ids 需要删除的数据
     * @return
     */
    @Override
    public int deleteOperaLogByIds(String ids) {
        return operaLogMapper.deleteOperaLogByIds(Convert.toStrArray(ids));
    }

    /**
     * 查询操作日志详细
     *
     * @param id 操作ID
     * @return 操作日志对象
     */
    @Override
    public SysOperaLog selectOperaLogById(String id) {
        SysOperaLog param = new SysOperaLog();
        param.setId(id);
        return list(param).stream().findFirst().orElse(param);
    }

    /**
     * 清空操作日志
     */
    @Override
    public void cleanOperaLog() {
        operaLogMapper.cleanOperaLog();
    }
}
